/**
 * Android FriendFeed Client
 * Copyright (C) 2010 E & B Labs
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package net.eblabs.androidfriendfeedclient;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONArray;
import org.json.JSONException;

/**
 *
 * @author epplestun
 */
public class FriendfeedCommentsListActivity extends Activity {
    private ArrayList<FriendfeedComment> mComments = null;
    private FriendfeedCommentsAdapter mAdapter;
    private ListView list;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.comments);

        setTitle(R.string.comments_list_title);

        Intent getIntent = getIntent();
        Bundle entry = getIntent.getBundleExtra("entry");

        try {
            JSONArray comments = new JSONArray(entry.getString("comments"));

            this.mComments = FriendfeedComment.commentsToArrayList(comments);
            this.mAdapter = new FriendfeedCommentsAdapter(this, R.layout
                    .commentrow, this.mComments);
            this.list = (ListView) findViewById(R.id.comments_list);
            this.list.setAdapter(this.mAdapter);
        } catch (JSONException ex) {
            Logger.getLogger(FriendfeedCommentsListActivity.class.getName())
                    .log(Level.SEVERE, null, ex);
        }
    }

    /* {@inheritDoc}. */
    @Override
    protected final void onStop() {
        super.onStop();
    }
}
